<%@page import="java.util.ArrayList"%>
<%@page import="cn.sendto.model.ResidentInfoModel"%>
<%@page import="java.util.List"%>
<%@page import="cn.sendto.service.ResidentInfoService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" errorPage="../err.jsp"%>
    <jsp:include page="../lock.jsp"></jsp:include>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生班级列表</title>
<style >
.txt20 {
	font-size: 20px;
}

.input {
	width: 60px;
	height: 25px;
}
a{
	text-decoration: none;
}
</style>
</head>

<body>
<div class="txt20">当前位置-->学生班级信息</div>
<%
	request.setCharacterEncoding("UTF-8");
	
	ResidentInfoService ris = new ResidentInfoService();
	String select = request.getParameter("select");
	String type = request.getParameter("type");
	
%>
	<form action="residentlist.jsp" method="post">
	<span>搜索关键字：</span>&nbsp;
		<input type="text" name="select" placeholder="请输入要查询关键字">
		<!-- 性别： <select name="type">
			<option value="0" selected="selected">全部</option>
			<option value="1">男</option>
			<option value="2">女</option>
		</select>  -->
		&nbsp;&nbsp;<input type="submit" name="查询" value="查询" value="查询" class="input">
	</form>
	
	<div align="right" style="width:95%;font-size:25px;"><a href="addresident.jsp" >添加学生班级</a></div>
	
	<%
	if (request.getAttribute("residentinfo") != null) {
		out.print("<span style='color:red'>"+request.getAttribute("residentinfo")+"</span>");
	}
			List<ResidentInfoModel> list = new ArrayList<ResidentInfoModel>();
			 if (select == null  && type == null ) {
				list = ris.allUser();
				out.print("目前共有班级"+list.size()+"个");
			} 
			if (type != null && (select == null  || select.equals(""))) {
				list = ris.select(select, type);
				out.print("查询到班级"+list.size()+"个");
			}else if(select != null && type != null ){
				list = ris.select(select, type);
				out.print("查询到班级"+list.size()+"个");
			}
			if(list.size() > 0){
	%>
<div>
		<table width="95%" class="txt12" style="background-color: #00BBEE"
			cellspacing="1" cellpadding="0">
			<tr style="background-color: #EEEEEE; height: 30px">
				<th>序号</th>
				<th>用户名</th>
				<th>姓名</th>
				<th>联系电话</th>
				<th>类型</th>
				
				<th>修改</th>
				<th>删除</th>
			</tr>
			<%
				for (int i = 0; i < list.size(); i++) {
					
			%>
			<tr style="background-color: white; height: 25px;">
				<td align="center"><%=i+1 %></td>
				<td align="center"><%=list.get(i).getUserName()%></td>
				<td align="center"><%=list.get(i).getName()%></td>
				<td align="center"><%=list.get(i).getTellphone()%></td>
				<td align="center">学生</td>
				<td align="center">
					<a href="modresident.jsp?id=<%=list.get(i).getResidentId()%>"><img src="../img/edit.gif"> </a>
				</td>
				<td align="center">
					<a href="delresident.jsp?id=<%=list.get(i).getResidentId()%>" onclick="return confirm('是否删除此用户？(同时此用户的其他信息也将删除)')"> <img src="../img/delimg.gif"> </a>
				</td>
			</tr>
			<%
				}
	}
			%>
		</table>
	</div>
</body>
</html>